package com.wtx.fitness.exception;

import com.wtx.fitness.common.ResultCode;

/**
 * 业务异常
 * 用于表示业务逻辑错误，如参数校验失败、数据不符合业务规则等
 */
public class BusinessException extends RuntimeException {

  private int code;

  public BusinessException(String message) {
    super(message);
    this.code = ResultCode.PARAM_ERROR.getCode();
  }

  public BusinessException(ResultCode resultCode) {
    super(resultCode.getMessage());
    this.code = resultCode.getCode();
  }

  public BusinessException(ResultCode resultCode, String message) {
    super(message);
    this.code = resultCode.getCode();
  }

  public BusinessException(int code, String message) {
    super(message);
    this.code = code;
  }

  public int getCode() {
    return code;
  }
}